var t = getApp();

Page({
    data: {
        winHeight: "",
        currentTab: 0,
        scrollLeft: 0,
        picLayer: !1,
        list: [],
        listId: 0,
        isChoose: !1,
        detailList: [],
        inint: 0,
        detailallList: [],
        lastX: 0,
        lastY: 0,
        server: t.server,
        serverUrl: t.serverUrl
    },
    onLoad: function(a) {
        var i = this;
        t.request({
            url: t.server + "/productApi/getFullSceneCat",
            method: "POST",
            data: {
                token: t.token
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(a) {
                console.log(a);
                var e = [], s = !0, n = !1, l = void 0;
                try {
                    for (var r, o = a.data.result.data[Symbol.iterator](); !(s = (r = o.next()).done); s = !0) {
                        var d = r.value;
                        if (d.children) {
                            var c = !0, h = !1, u = void 0;
                            try {
                                for (var f, p = d.children[Symbol.iterator](); !(c = (f = p.next()).done); c = !0) {
                                    var g = f.value;
                                    e.push(g);
                                }
                            } catch (t) {
                                h = !0, u = t;
                            } finally {
                                try {
                                    !c && p.return && p.return();
                                } finally {
                                    if (h) throw u;
                                }
                            }
                        }
                    }
                } catch (t) {
                    n = !0, l = t;
                } finally {
                    try {
                        !s && o.return && o.return();
                    } finally {
                        if (n) throw l;
                    }
                }
                i.setData({
                    list: e,
                    listId: e[0].id
                }), t.request({
                    url: t.server + "/productApi/getFullSceneCatInfo",
                    method: "POST",
                    data: {
                        token: t.token,
                        cid: e[0].id
                    },
                    header: {
                        "content-type": "application/x-www-form-urlencoded"
                    },
                    success: function(t) {
                        console.log("res:", t);
                        var a = i.data.list;
                        console.log(i.data.list), a[0].data = t.data.result.list, console.log(a), i.setData({
                            list: a
                        });
                    }
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        wx.setNavigationBarTitle({
            title: "360度"
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    choose: function(t) {
        var a = this, i = t.currentTarget.dataset.index, e = t.currentTarget.dataset.subindex, s = this.data.list[i].data[e], n = s.pic_product.pic;
        a.data.detailallList = n, a.setData({
            picLayer: !0,
            detailList: s.pic_product.pic[a.data.inint]
        });
    },
    prePic: function() {
        this.data.inint >= 0 ? (this.data.inint--, this.setData({
            detailList: this.data.detailallList[this.data.inint]
        })) : (this.data.inint = this.data.detailallList.length - 1, this.setData({
            detailList: this.data.detailallList[this.data.inint]
        }));
    },
    nextPic: function(t) {
        console.log(t), this.data.inint < this.data.detailallList.length ? (this.data.inint++, 
        console.log(this.data.detailallList[this.data.inint]), this.setData({
            detailList: this.data.detailallList[this.data.inint]
        })) : (this.data.inint = 0, this.setData({
            detailList: this.data.detailallList[this.data.inint]
        }));
    },
    handletouchmove: function(t) {
        console.log(t);
        var a = t.touches[0].pageX, i = t.touches[0].pageY;
        console.log(a), console.log(this.data.lastX);
        a - this.data.lastX < 0 ? this.prePic() : a - this.data.lastX > 0 && this.nextPic(), 
        this.data.lastX = a, this.data.lastY = i, this.setData({
            text: ""
        });
    },
    offPicLayer: function() {
        this.setData({
            picLayer: !1
        });
    },
    switchTab: function(a) {
        var i = this;
        this.setData({
            currentTab: a.detail.current
        }), console.log(this.data.list[a.detail.current].id), this.checkCor(), this.setData({
            listId: this.data.list[a.detail.current].id
        }), t.request({
            url: t.server + "/productApi/getFullSceneCatInfo",
            method: "POST",
            data: {
                token: t.token,
                cid: i.data.list[a.detail.current].id
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                var e = i.data.list;
                e[a.detail.current].data = t.data.result.list, i.setData({
                    list: e
                });
            }
        }), console.log(this.data.list);
    },
    swichNav: function(a) {
        console.log(this.data.currentTab), console.log(this.data.list), console.log(a.currentTarget.dataset.id);
        for (var i, e = this, s = 0; s < this.data.list.length; s++) this.data.list[s].id === a.currentTarget.dataset.id && (i = s);
        if (this.data.currentTab == i) return !1;
        this.setData({
            currentTab: i
        }), t.request({
            url: t.server + "/productApi/getFullSceneProductList",
            method: "POST",
            data: {
                token: t.token,
                cid: a.currentTarget.dataset.id
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                var a = e.data.list;
                a[i].data = t.data.result.list, e.setData({
                    list: a
                });
            }
        });
    },
    checkCor: function() {
        this.data.currentTab > 4 ? this.setData({
            scrollLeft: 300
        }) : this.setData({
            scrollLeft: 0
        });
    }
});